package pid

import (
	"fmt"
	"time"
)

func DischargeLoadTrack() {
	battery := Battery{
		SOC:            20.01, // 初始电池SOC
		DischargePower: 0,     // 初始放电功率
		DesiredSOC:     20,    // 目标 SOC
		PID: PID{
			Kp: 0.1,
			Ki: 0.01,
			Kd: 0.1,
		},
		LoadTracking: LoadTrackingControl{
			BasePower:  50,
			MaxPower:   200,
			MinPower:   10,
			Adjustment: 0.5,
		},
	}

	fmt.Printf("Initial SOC: %.2f%%\n", battery.SOC)

	for i := 0; i < 100; i++ {
		time.Sleep(1 * time.Second)                  // 模拟时间流逝
		currentLoad := 35.0                          // 模拟负荷需求
		battery.UpdateDischargePower(currentLoad, 1) // 更新放电功率
		fmt.Printf("Updated SOC: %.2f%% DischaregPower:%f\n", battery.SOC, battery.DischargePower)
	}
}
